package com.central.apps.handler;

import com.central.app.service.HandlerService;
import com.central.apps.handler.base.LvBaseHandler;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2022/7/19.
 */
@Log4j2
@Component
public class LowTestHandler extends LvBaseHandler {

    @Autowired
    private HandlerService handlerService;
    public void beforSave(String app, String objName, Map<String, Object> data, boolean isUpdate) throws Exception {
        if("lowtestApp".equals(app)){
            String username = MapUtils.getString(data, "username");
            List< Map<String,Object>> list = handlerService.findBySql("select * from gq_lowtest where username = " + username);
            if(list.size()>0){
                data.put("username","重复名字");
            }

        }

    }
}
